package edu.hunau.recommend.common;

import java.security.MessageDigest;
import java.util.Base64;

/**
 * md5的工具类
 * @author name
 * @creater 2022-09-09-10:01
 */
public class MD5Utils {
    public static String md5(String str){

        try {
            MessageDigest instance = MessageDigest.getInstance("MD5");
            Base64.Encoder encoder = Base64.getEncoder();
            byte[] encode = encoder.encode(instance.digest(str.getBytes("utf-8")));
            return new String(encode,"utf-8");
        }catch (Exception e){
            throw new RuntimeException(e);
        }

    }
}
